<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="common.*,Dao.*,vo.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%

request.setCharacterEncoding("utf-8");
Userdao dao = new Userdao();
String id = request.getParameter("id");
int id2 = Integer.valueOf(id);

String username = request.getParameter("username");
String gender = request.getParameter("options");
String email = request.getParameter("email");
String phone = request.getParameter("phone");

User user = new User();
user.setUsername(username);
user.setGender(gender);
user.setEmail(email);
user.setPhone(phone);


boolean re = dao.isExitUname_user(email,id2);
if(re){
	%>
	<script type="text/javascript">
	window.alert("邮箱已被注册！");
	window.location.href="user_select.jsp";
	</script>
	<% 
}else{
int result = dao.do_change(id,user);
if(result>0){
	%>
	<script type="text/javascript">
	window.alert("修改成功！");
	window.location.href="user_select.jsp";
	</script>
	<% 
}else{
	%>
	<script type="text/javascript">
	window.alert("修改失败！<%=id%>");
	window.location.href="user_select.jsp";
	</script>
	<%
}
}
%>
</body>
</html>